# 简单测试添加文件类型的API端点

$baseUrl = "http://localhost:5269/api/file/types"
$randomId = Get-Random -Minimum 1000 -Maximum 9999
$testTypeName = "测试类型$randomId"
$testMemoryStrength = 1.2

Write-Host "测试添加文件类型API: $baseUrl"

# 构建请求体
$requestBody = @{
    TypeName = $testTypeName
    MemoryStrength = $testMemoryStrength
}

# 发送POST请求
try {
    $response = Invoke-WebRequest -Uri $baseUrl -Method Post -Body (ConvertTo-Json $requestBody) -ContentType "application/json"
    Write-Host "请求成功！状态码: $($response.StatusCode)"
    Write-Host "返回内容: $($response.Content)"
} catch {
    Write-Host "请求失败！"
    Write-Host "错误: $($_.Exception.Message)"
    if ($_.Exception.Response) {
        Write-Host "状态码: $($_.Exception.Response.StatusCode.value__)"
        Write-Host "响应内容: $($_.ErrorDetails.Message)"
    }
}